package org.lq.user.service.impl;

import java.util.List;

import org.lq.user.dao.UsersDao;
import org.lq.user.dao.impl.UsersDaoImpl;
import org.lq.user.entity.Users;
import org.lq.user.service.UsersService;

public class UsersServiceImpl implements UsersService {

	UsersDao udao = new UsersDaoImpl();
	
	@Override
	public boolean saveUser(Users u) {
		return udao.saveUser(u)>0;
	}

	@Override
	public boolean updateUser(Users u) {
		return udao.updateUser(u)>0;
	}

	@Override
	public boolean deleteUser(int id) {
		return udao.deleteUser(id)>0;
	}

	@Override
	public List<Users> findPage(int pageIndex, int pageSize) {
		return udao.findPage(pageIndex, pageSize);
	}

	@Override
	public int totalCount() {
		return udao.totalCount();
	}

	@Override
	public Users login(String username, String password) {
		return udao.login(username, password);
	}

	@Override
	public int totalPage(int pageSize) {
		int count = totalCount();
		return count% pageSize == 0 ? count/pageSize : count / pageSize +1;
	}

}
